package top.oylan.manager.controller.api;

import io.swagger.annotations.Api;
import org.springframework.beans.BeanUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import top.oylan.manager.entity.Types;
import top.oylan.manager.entity.api.CourseIndexApi;
import top.oylan.manager.entity.api.entity.VideoTypeEntity;
import top.oylan.manager.service.TypeService;
import top.oylan.manager.tools.ApiUtils;

import javax.annotation.Resource;

/**
 * @Author abduahad
 * @Description ${description}
 * @Date 2019-06-15
 */
@RestController
@RequestMapping("/api/course")
@Api(value = "course", description = "课程相关", produces = MediaType.APPLICATION_JSON_VALUE)
public class ApiCourseController{

    @Resource
    TypeService typeService;

    @RequestMapping(value = "/index",method = RequestMethod.GET)
    public CourseIndexApi index(){

        CourseIndexApi courseIndexApi = new CourseIndexApi();
        Types type = typeService.selectCourseCategories();
        VideoTypeEntity videoTypeEntity = new VideoTypeEntity();
        BeanUtils.copyProperties(type, videoTypeEntity);
        ApiUtils.addRightData(courseIndexApi,"成功",type);
        return courseIndexApi;
    }
}
